﻿using System;
using System.Windows.Input;
using ClientOverflow.ViewModels.MainMenus;
using ClientOverflow.ViewModels.QuestionViewViewModels;

namespace ClientOverflow.ViewModels.QuestionsListViewModels
{
    /// <summary>
    /// ShowQuestionCommand is a command that performs the navigation from the questions list to a
    /// single question view that includes the details of the question.
    /// </summary>
    internal class ShowQuestionCommand : ICommand
    {
        private readonly DataTransferObjects.Question question;
        private readonly IMenusViewModel viewModel;

        public ShowQuestionCommand(DataTransferObjects.Question question, IMenusViewModel viewModel)
        {
            this.question = question;
            this.viewModel = viewModel;
        }

        public void Execute(object parameter)
        {
            viewModel.Content = QuestionViewViewModel.CreateQuestionViewViewModel(question);
        }

        public bool CanExecute(object parameter)
        {
            return true;
        }

        public event EventHandler CanExecuteChanged;
    }
}